﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MakeIT.MiraPark.Negocios;
using MakeIT.MiraPark.Apresentacao.Rotinas;
using Microsoft.Reporting.WinForms;

namespace MiraPark{

    public partial class FormReportCobrancaConvenio : Form
    {
        public FormReportCobrancaConvenio()
        {
            InitializeComponent();
        }

        private void FormTesteRelatorio_Load(object sender, EventArgs e)
        {
            //reportViewer1.LocalReport.SubreportProcessing +=
            //        new SubreportProcessingEventHandler(CobrancaConvenio_SubreportProcessingEventHandler);

            this.reportViewer1.RefreshReport();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public void setDataSource(List<MovimentacaoVO> listMovimentacaoVOs, List<RelMovConvVO> listRelMovConvVO, string convenio1, string convenio2, string vencimento, string valorTotal)
        {
            List<ReportParameter> rps = new List<ReportParameter>();
            rps.Add(new ReportParameter("Empresa", ModelBO.getEmpresa(int.Parse(ModelBO.getParametro("Empresa Ativa"))).nome));
            rps.Add(new ReportParameter("Convenio1", convenio1));
            rps.Add(new ReportParameter("Convenio2", convenio2));
            rps.Add(new ReportParameter("Vencimento", vencimento));
            rps.Add(new ReportParameter("ValorTotal", valorTotal));

            this.reportViewer1.LocalReport.SetParameters(rps);

            this.BindingSource.DataSource = listRelMovConvVO; // listMovimentacaoVOs;

        }

        private void CobrancaConvenio_SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
        {
            TabelaAvulsoVO tabelaAvulsoVO = TabelaAvulsoVO.CreateTabelaAvulsoVO();
            int rowNum = int.Parse(e.Parameters["rowNum"].Values[0]) -1;

            List<MovimentacaoVO> listMovimentacaoVOs = (List<MovimentacaoVO>)this.BindingSource.DataSource;

            e.DataSources.Add(new ReportDataSource(e.DataSourceNames[0], listMovimentacaoVOs[rowNum].movimentoVOs));

        }
    
    
    }
}
